<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 200px;
            margin: 0 auto;
            margin-top: 10px;

            background-color: pink;
        }
    </style>
</head>

<body>
    <div>
        <div class="btn">×</div>
    </div>
    <div>
        <div class="btn">×</div>
    </div>
    <div>
        <div class="btn">×</div>
    </div>
    <script>
        const btns = document.querySelectorAll('.btn') //注意是把所有的按钮都获取过来
        for (let i = 0; i < btns.length; i++) {
            btns[i].addEventListener('click', function () {
                this.parentNode.style.display = 'none'
            })
        }
    </script>
</body>

</html>